<template>
  <div class="testApp">
    <top></top>
    <div class="head">
      <step :index="currentIndex" id="1" name="输入邮箱密码"></step>
      <span class="border" :class="{ downborder: currentIndex > 1 }"></span>

      <step :index="currentIndex" id="2" name="请输入邮箱验证码"></step>
      <span class="border" :class="{ downborder: currentIndex > 2 }"></span>

      <step :index="currentIndex" id="3" name="设置新密码"></step>
      <span class="border" :class="{ downborder: currentIndex > 3 }"></span>
      <step :index="currentIndex" id="4" name="完成"></step>
    </div>

    <div class="btn">
      <step-1 @next="next" v-if="currentIndex === 1"></step-1>
      <step-2 @next="next" v-if="currentIndex === 2"></step-2>
      <step-3 @next="next" v-if="currentIndex === 3"></step-3>
      <step-4 @next="next" v-if="currentIndex === 4"></step-4>
    </div>
  </div>
</template>

<script>
import step from '../../components/step.vue'
import step1 from './components/step1.vue'
import step2 from './components/step2.vue'
import step3 from './components/step3.vue'
import step4 from './components/step4.vue'
import top from './components/top.vue'

export default {
  components: {
    step,
    step1,
    step2,
    step3,
    step4,
    top
  },
  data () {
    return {
      currentIndex: Number(window.sessionStorage.getItem('index')) || 1,
      arr: []
    }
  },
  created () {
    this.currentIndex = 1
  },
  methods: {
    next () {
      var index = ++this.currentIndex
      // console.log(index)
      if (index >= 4) {
        index = 1
      }
      window.sessionStorage.setItem('index', index)
    }

  }
}
</script>

<style lang="scss" scoped>
.testApp {
  width: 100%;
  min-height: 1080px;
  position: relative;

  background-color: #f2f4f8;
  overflow: hidden;
  .head {
    width: 1440px;
    height: 44px;
    line-height: 44px;
    margin: 30px auto;
    text-align: center;
    .border {
      display: inline-block;
      width: 264px;
      height: 1px;
      background: #ccc;
      vertical-align: middle;
      margin-right: 12px;
    }
    .downborder {
      background: #304eec;
    }
  }
  .btn {
    width: 1440px;
    height: 830px;
    opacity: 1;
    position: absolute;
    background: #ffffff;
    top: 160px;
    bottom: 90px;
    left: 50%;
    transform: translateX(-50%);
  }
}
</style>
